home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / gfx / show / gs503_data.lha / Ghostscript / data / gs_pfile.ps < prev    next >
Text File  |  1997-08-14  |  4KB  |  129 lines

  1. %    Copyright (C) 1994, 1995 Aladdin Enterprises.  All rights reserved.
  2. % This file is part of Aladdin Ghostscript.
  3. % Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  4. % or distributor accepts any responsibility for the consequences of using it,
  5. % or for whether it serves any particular purpose or works at all, unless he
  6. % or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  7. % License (the "License") for full details.
  8. % Every copy of Aladdin Ghostscript must include a copy of the License,
  9. % normally in a plain ASCII text file named PUBLIC.  The License grants you
  10. % the right to copy, modify and redistribute Aladdin Ghostscript, but only
  11. % under certain conditions described in the License.  Among other things, the
  12. % License requires that the copyright notice and this notice be preserved on
  13. % all copies.
  14.  
  15. % Runtime support for minimum-space fonts and packed files.
  16.  
  17. % ****** NOTE: This file must be kept consistent with
  18. % ****** packfile.ps and wrfont.ps.
  19.  
  20. % ---------------- Packed file support ---------------- %
  21.  
  22. % A packed file is the concatenation of several file groups, each of which
  23. % is the result of compressing several files concatenated together.
  24. % The packed file begins with a procedure that creates an appropriate
  25. % decoding filter for each file group, as follows:
  26. %    <group-subfile-filter> -proc- <group-decode-filter>
  27. % Thus, accessing an individual file requires 4 parameters:
  28. % the starting address and length of the outer compressed file,
  29. % and the starting address and length of the inner file.
  30. /.packedfilefilter    % <file> <ostart> <olength> <istart> <ilength>
  31.             %   .packedfilefilter <filter>
  32.  { 4 index systemdict begin token pop end 6 1 roll
  33.     % Stack: fproc file ostart olength istart ilength
  34.    4 index 5 -1 roll setfileposition
  35.     % Stack: fproc file olength istart ilength
  36.    4 -2 roll () /SubFileDecode filter
  37.     % Stack: fproc istart ilength ofilter
  38.    4 -1 roll exec
  39.     % Filters don't support setfileposition, so we must skip data
  40.     % by reading it into a buffer.  We rely on the fact that
  41.     % save/restore don't affect file positions.
  42.     % Stack: istart ilength dfilter
  43.    save exch 1000 string
  44.     % Stack: istart ilength save dfilter scratch
  45.    4 index 1 index length idiv { 2 copy readstring pop pop } repeat
  46.    2 copy 0 8 -1 roll 2 index length mod getinterval readstring pop pop pop
  47.     % Stack: ilength save dfilter
  48.    exch restore exch () /SubFileDecode filter
  49.  } bind def
  50.  
  51. % Run a packed library file.
  52. /.runpackedlibfile    % <filename> <ostart> <olength> <istart> <ilength>
  53.             %   .runpackedlibfile
  54.  { 5 -1 roll findlibfile
  55.     { exch pop dup 6 2 roll .packedfilefilter
  56.       currentobjectformat exch 1 setobjectformat run
  57.       setobjectformat closefile
  58.     }
  59.     { 5 1 roll /findlibfile load /undefinedfilename signalerror
  60.     }
  61.    ifelse
  62.  } bind def
  63.  
  64. % ---------------- Compacted font support ---------------- %
  65.  
  66. % Compacted fonts written by wrfont.ps depend on the existence and
  67. % specifications of the procedures and data in this section.
  68.  
  69. /.compactfontdefault mark
  70.     /PaintType 0
  71.     /FontMatrix [0.001 0 0 0.001 0 0] readonly
  72.     /FontType 1
  73.     /Encoding StandardEncoding
  74. .dicttomark readonly def
  75.  
  76. /.checkexistingfont    % <fontname> <uid> <privatesize> <fontsize>
  77.             %   .checkexistingfont
  78.             %   {} (<font> on d-stack)
  79.             % <fontname> <uid> <privatesize> <fontsize>
  80.             %   .checkexistingfont
  81.             %   -save- --restore-- (<font> on d-stack)
  82.  { FontDirectory 4 index .knownget
  83.     { dup /UniqueID .knownget
  84.        { 4 index eq exch /FontType get 1 eq and }
  85.        { pop false }
  86.       ifelse
  87.     }
  88.     { false
  89.     }
  90.    ifelse
  91.     { save /restore load 6 2 roll }
  92.     { {} 5 1 roll }
  93.    ifelse
  94.    dict //.compactfontdefault exch .copydict begin
  95.    dict /Private exch def
  96.    Private begin
  97.      /MinFeature {16 16} def
  98.      /Password 5839 def
  99.      /UniqueID 1 index def
  100.    end
  101.    /UniqueID exch def
  102.    /FontName exch def
  103.  } bind def
  104.  
  105. /.knownEncodings [
  106.    ISOLatin1Encoding
  107.    StandardEncoding
  108.    SymbolEncoding
  109. ] readonly def
  110.  
  111. /.readCharStrings    % <count> <encrypt> .readCharStrings <dict>
  112.  { exch dup dict dup 3 -1 roll
  113.     { currentfile token pop dup type /integertype eq
  114.        { dup -8 bitshift //.knownEncodings exch get exch 255 and get } if
  115.       currentfile token pop dup type /nametype eq
  116.        { 2 index exch get
  117.        }
  118.        {    % Stack: encrypt dict dict key value
  119.      4 index { 4330 exch dup .type1encrypt exch pop } if
  120.      readonly
  121.        }
  122.       ifelse put dup
  123.     }
  124.    repeat pop exch pop
  125.  } bind def
  126.